<template>
  <j-modal
    :width="modalWidth"
    :visible="visible"
    :title="title"
    switchFullscreen
    @ok="handleSubmit"
    @cancel="close"
    style="top:50px"
    cancelText="关闭">

    <a-card :bordered='false'>
      <!-- 查询区域 -->
      <div class='table-page-search-wrapper'>
        <a-form layout='inline' @keyup.enter.native='searchQuery'>
          <a-row :gutter='24'>
            <!--          <a-col :xl='6' :lg='7' :md='8' :sm='24'>-->
            <!--            <a-form-item label='创建人'>-->
            <!--              <a-input placeholder='请输入创建人' v-model='queryParam.createBy'></a-input>-->
            <!--            </a-form-item>-->
            <!--          </a-col>-->
            <a-col :xl='6' :lg='7' :md='8' :sm='24'>
              <!--            <a-form-item label='创建日期'>-->
              <!--              <j-date  date-format='YYYY-MM-DD HH:mm:ss' placeholder='请选择创建日期'-->
              <!--                      v-model='queryParam.createTime'></j-date>-->
              <!--            </a-form-item>-->
              <a-form-item label="创建日期">
                <j-date placeholder="请选择创建日期" date-format='YYYY-MM-DD HH:mm:ss' v-model="queryParam.createTime"></j-date>
              </a-form-item>
            </a-col>
            <template v-if='toggleSearchStatus'>
              <a-col :xl='6' :lg='7' :md='8' :sm='24'>
                <a-form-item label='单据编号'>
                  <a-input placeholder='请输入单据编号' v-model='queryParam.code'></a-input>
                </a-form-item>
              </a-col>
            </template>
            <a-col :xl='6' :lg='7' :md='8' :sm='24'>
            <span style='float: left;overflow: hidden;' class='table-page-search-submitButtons'>
              <a-button type='primary' @click='searchQuery' icon='search'>查询</a-button>
              <a-button type='primary' @click='searchReset' icon='reload' style='margin-left: 8px'>重置</a-button>
              <a @click='handleToggleSearch' style='margin-left: 8px'>
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
      <!-- 查询区域-END -->

      <!-- table区域-begin -->
      <div>
        <div class='ant-alert ant-alert-info' style='margin-bottom: 16px;'>
          <i class='anticon anticon-info-circle ant-alert-icon'></i> 已选择 <a
          style='font-weight: 600'>{{ selectedRowKeys.length }}</a>项
          <a style='margin-left: 24px' @click='onClearSelected'>清空</a>
        </div>

        <a-table
          ref='table'
          size='middle'
          bordered
          rowKey='id'
          class='j-table-force-nowrap'
          :scroll='{x:true}'
          :columns='columns'
          :dataSource='dataSource'
          :pagination='ipagination'
          :loading='loading'
          :rowSelection='{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type: checkval}'
          @change='handleTableChange'>
        </a-table>
      </div>
    </a-card>
  </j-modal>
</template>
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import '@/assets/less/TableExpand.less'
import ActApplyBtn from "@views/flowable/components/ActApplyBtn";
import ActCancelBtn from "@views/flowable/components/ActCancelBtn";
import ActHandleBtn from "@views/flowable/components/ActHandleBtn";
import ActHistoricDetailBtn from "@views/flowable/components/ActHistoricDetailBtn";
import { getAction } from '@api/manage'
import {mixinDevice} from '@/utils/mixin'
export default {
  name: 'BussContractReviewDesList',
  mixins: [JeecgListMixin,mixinDevice],
  components: {
    ActApplyBtn,
    ActCancelBtn,
    ActHandleBtn,
    ActHistoricDetailBtn
  },
  props: {
    category: {
      type: String
    },
    modalWidth: {
      type: Number,
      required: false,
      default: 1250
    },
    checkval: {
      type: String,
      default: 'radio'
    }
  },
  data() {
    return {
      description: '合同评审说明管理页面',
      visible: false,
      title: '选择评审说明',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '单据编号',
          align: 'center',
          dataIndex: 'code'
        },
        {
          title: '客户',
          align: 'center',
          dataIndex: 'customerId_dictText'
        },
        {
          title: '柜数',
          align: 'center',
          dataIndex: 'cabinetCount'
        },
        {
          title:'流程状态',
          align:"center",
          dataIndex: 'actStatus'
        },
      ],
      url: {
        list: '/business/bussContractReviewDes/list',
        delete: '/business/bussContractReviewDes/delete',
        deleteBatch: '/business/bussContractReviewDes/deleteBatch',
        exportXlsUrl: '/business/bussContractReviewDes/exportXls',
        importExcelUrl: 'business/bussContractReviewDes/importExcel'

      },
      dictOptions: {},
      superFieldList: []
    }
  },
  created() {
    this.getSuperFieldList()

  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    handleSubmit() {
      console.log("点击确定了")
      console.log('获取的数据',this.selectedRowKeys)
      this.getGoodsSelectRows();
      // this.searchReset(0)
      this.close();
    },
    add() {
      this.showModal();
    },
    showModal() {
      this.visible = true;
      this.loadData();
    },
    getGoodsSelectRows() {
      let selectedRow = null;
      if(this.checkval=='radio'){
        selectedRow = this.selectionRows[0];
      }else{
        selectedRow = this.selectedRowKeys
      }
      // let selectedRow = this.selectionRows[0];
      //传递选中的数据
      this.$emit("goodsOk", selectedRow);
    },
    initDictConfig() {
    },
    close() {
      this.searchReset(false);
      this.visible = false;
    },
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'createBy', text: '创建人', dictCode: '' })
      fieldList.push({ type: 'datetime', value: 'createTime', text: '创建日期' })
      fieldList.push({ type: 'string', value: 'sysOrgCode', text: '所属部门', dictCode: '' })
      fieldList.push({ type: 'string', value: 'code', text: '单据编号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'customerId', text: '客户', dictCode: 'erp_customer,name,id' })
      fieldList.push({ type: 'Text', value: 'formulaReq', text: '配方要求', dictCode: '' })
      fieldList.push({ type: 'Text', value: 'packReq', text: '包装要求', dictCode: '' })
      fieldList.push({ type: 'BigDecimal', value: 'weight', text: '重量', dictCode: '' })
      fieldList.push({ type: 'string', value: 'weightUnit', text: '重量单位', dictCode: 'zl_unit' })
      fieldList.push({ type: 'string', value: 'cabinetCount', text: '柜数', dictCode: '' })
      fieldList.push({ type: 'string', value: 'extra', text: '柜数单位', dictCode: '' })
      fieldList.push({ type: 'string', value: 'transactionMethod', text: '成交方式', dictCode: '' })
      fieldList.push({ type: 'string', value: 'shipPort', text: '发货港', dictCode: '' })
      fieldList.push({ type: 'string', value: 'destPort', text: '目的港', dictCode: '' })
      fieldList.push({ type: 'string', value: 'financeRemark', text: '财务备录', dictCode: '' })
      fieldList.push({ type: 'string', value: 'payMethod', text: '付款方式', dictCode: '' })
      fieldList.push({ type: 'int', value: 'daysArrival', text: '到货后付全款天数', dictCode: '' })
      fieldList.push({ type: 'string', value: 'deliveryTime', text: '交货期', dictCode: '' })
      fieldList.push({ type: 'string', value: 'overflowShort', text: '溢短装', dictCode: '' })
      fieldList.push({ type: 'string', value: 'customer', text: '客户类型', dictCode: '' })
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>